home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / UTILITY / DDIFF32.ARJ / DDIFF.DOC next >
Text File  |  1992-07-28  |  20KB  |  502 lines

  1.  
  2.  
  3. DDIFF
  4. A file difference reporting utility
  5.  
  6. version 3.2
  7. 7-28-92
  8. by Doug McKay
  9. Copyright (c) 1990, 1992  All Rights Reserved
  10. What it is . . .
  11.      DDIFF is a program that will check to see if any files in a specified
  12. directory tree have changed since the last time the utility was run.
  13.  
  14. Why use it . . .
  15.      If you want to find out what files have changed recently in a certain
  16. directory (or directory tree), DDIFF will come in handy.  It is especially
  17. helpful on a network where many people may have access to certain files that
  18. you need to keep track of.  There are some useful examples of DDIFF toward the
  19. end of this document.
  20.  
  21. How it does it . . .
  22.      DDIFF creates either one or two files for its own use depending upon how
  23. you wish to use it.
  24.  
  25.      The first is a Benchmark file containing the date and time of the last
  26. time the utility was run.  It also contains a list of all of the files in the
  27. directory along with their dates, times, and sizes as they were at the time the
  28. Benchmark file was created.
  29.  
  30.      Here is a portion of a Benchmark file:
  31.  
  32. ;DDIFF Benchmark created   7-2-1990 at 15:10
  33. ;
  34. >C:\*.*
  35. IO      .SYS+     33337  12-19-1988   0:00:02  A34D
  36. MSDOS   .SYS+     37376  04-19-1989   8:38:32  CE44
  37. DOUG'S      +         0  04-25-1990  14:33:30  ----
  38. BIZLINK     +    <DIR>   06-06-1990   9:22:18  ----
  39. DOS         +    <DIR>   04-25-1990  14:02:46  ----
  40. WP51        +    <DIR>   04-25-1990  14:25:52  ----
  41. AUTOEXEC.BAT~      1668  07-02-1990  11:10:36   F44
  42. COMMAND .COM+     37557  12-19-1988   0:00:02  7633
  43. CONFIG  .SYS~       370  07-02-1990  13:58:12  D912
  44. ;
  45. >C:\BIZLINK\*.*
  46. DOUG             <DIR>   06-06-1990   9:24:34  ----
  47. ATTACH  .WPM~      3739  05-24-1990   0:00:00  591A
  48. ATTCHCTL.CMD~     18258  06-18-1990   0:00:00  2544
  49. BIZLINK .CMD~     43434  06-18-1990   0:00:00  B7C6
  50. BIZLINK .EXE`     48556  06-06-1990   0:00:00  2323
  51. ;
  52.  
  53.      Notice that DDIFF picks up Hidden, System, and Read Only files (IO.SYS and
  54. MSDOS.SYS).  The file "DOUG'S" is not a file, but the Volume label on drive C:. 
  55. You'll also notice that DDIFF considers the seconds on a file's time stamp to
  56. be significant (DOS doesn't display them, but they are there).  Even if someone
  57. resets the clock to the date and time that DOS displays for a particular file
  58. and then modifies that file, DDIFF will likely report a difference due to the
  59. seconds.
  60.  
  61.      The next file (if you tell DDIFF to create it) is a Difference file
  62. containing a list of all of the files that have been changed (according to
  63. date, time, and filesize) since the Benchmark file was created.
  64.  
  65.      Here is a portion of a Difference File:
  66.  
  67. ;
  68. ;DDIFF Difference file created  8-2-1990 at 11:39
  69. ;Benchmark file used: 'DDIFF.LOG'.
  70. ;
  71. >C:\LIBRARY\*.*
  72. DM_}ED  .SET~     332  08-02-1990 11:18:22 C69A               Time
  73. ;    1 - Difference(s)
  74. ;
  75. >C:\TC\WORK\DDIFF\*.*
  76. DDIFF   .EXE~    14363 08-02-1990 11:29:16 9F3C CRC Size      Time
  77. DDIFF   .LOG~   155746 08-02-1990 11:30:32 77B2 CRC Size      Time
  78. DDIFF   .OBJ~    19380 08-02-1990 11:19:02 8F33          Date Time
  79. DDIFF   .DIF~      766 08-02-1990 11:23:36 AC4E                     Added
  80. DDIFF   .PRJ+     6435 08-02-1990 11:18:12 8BE7 CRC Size      Time
  81. DDIFF   .CPP~    36598 08-02-1990 11:18:46 7E15 CRC Size      Time
  82. DDIFF   .BAK~    36615 08-02-1990 11:14:38 ----                     Deleted
  83. ;    7 - Difference(s)
  84. ;
  85. ;   91 - total Directories processed
  86. ; 1255 - total Items processed
  87. ;    8 - total Difference(s)
  88.  
  89.  
  90.      Note that DDIFF will find HIDDEN directories that are newly added or
  91. deleted but will not check any files inside hidden directories for differences. 
  92. See the note about 'A Little Trick' below.
  93.  
  94.      When DDIFF checks your files, it reads the Benchmark file and compares it
  95. against the current contents of the directories that you told it to check.  If
  96. it finds files that have been changed, it writes a list of them to a Difference
  97. file (and/or optionally, to the screen).
  98.  
  99.  
  100.  
  101. Archive bit display
  102.  
  103.      
  104.      Note the '~' and '+' symbols to the right of the file extensions.  These
  105. characters tell you whether or not the file has been changed since the last
  106. time you backed up your hard disk (something that can never be done too often). 
  107. A '~' means that the file is not backed up.  It means that the file has been
  108. changed since the last backup and should be backed up again (ideally you won't
  109. have very many of these).  A '+' means that the file has been backed up and has
  110. not been changed since that time.  These symbols are controlled by the archive
  111. bit of the file.  DOS resets this flag each time the file is saved to disk, or
  112. is otherwise changed.  Most backup programs (indeed any that are worthwhile)
  113. will reset the archive bit (turn it off) on a file after the file has been suc-
  114. cessfully backed up.  For this reason, this flag is not used by DDIFF in deter-
  115. mining if a file is 'different', it is merely displayed as an informational
  116. item so that the user can tell when it's time to do another backup.
  117.  
  118. Running it . . .
  119.      DDIFF has many options that tell it exactly what you want it to do.  Each
  120. time you run it, DDIFF will essentially do one of two things, create a
  121. Benchmark file, or check a directory against an existing Benchmark file.
  122.  
  123. Usage:  DDIFF option [option...] [path\[filespec]...]
  124.  
  125.      ■    When running DDIFF, you can have DDIFF.EXE anywhere that DOS can find
  126.           it (in the current directory or in your path).
  127.      ■    You may specify any of DDIFF's options in any order whatsoever.
  128.      ■    If you specify two conflicting options (like /M and /I) the last one
  129.           encountered will take precedence.
  130.      ■    You must separate each option with a space.  If you do not, DDIFF
  131.           will not be able to distinguish between them.  For example, DDIFF
  132.           will interpret 'DDIFF /M/O' incorrectly (DDIFF will think you meant
  133.           'DDIFF /M-O'.
  134.      ■    The dash '-' characters in certain parameters are necessary, without
  135.           them, DDIFF will get confused about what you want it to do.
  136.      ■    If you do not specify any options, DDIFF displays its help screen.
  137.  
  138.      Since there are so many different command line options, the following
  139. section will explain each one in further detail.
  140.  
  141.  
  142. The Finer Points
  143.      This is part of DDIFF's help screen.  It displays a quick summary of each
  144. option.
  145.  
  146. Usage:  DDIFF option [option...] [path\[filespec...]]
  147.  
  148. Options
  149.  
  150.  /M-file      Make Benchmark file using 'file'
  151.  /C-file      Check directory using 'file' as a Benchmark.
  152.  /D-file      Write Difference file to 'file.'
  153.  /I-file      Create an infobase from the Difference file. (Need CREATE.EXE)
  154.  /R           Recursive operation (Operate on all subdirectories)
  155.  /CRC         CRC Checking on.  Much slower.
  156.  /U           Unchanged files written to Difference file.
  157.  /O           Overwrite old files.
  158.  /A           Append to files.
  159.  /H           Display this help screen.
  160.  path\        The 'path' to begin working in (MUST END WITH A '\' BACKSLASH)!
  161.  filespec     The filename mask (default is '*.*') to use in 'path.'
  162.  
  163.  
  164.  
  165.  
  166. /M-filename
  167.  
  168.      Make a Benchmark file using 'filename'.  If 'filename' is not specified,
  169. the name DDIFF.LOG is used.  This tells DDIFF to create a Benchmark file named
  170. DDIFF.LOG in the current directory.  Optionally you can specify a full path and
  171. filename to tell DDIFF to create the Benchmark somewhere else.
  172.  
  173.  
  174.  
  175. /C-filename
  176.  
  177.      Check a directory (or directory tree) against 'filename'.  If 'filename'
  178. is not specified, the name DDIFF.LOG is used.  This tells DDIFF to compare a
  179. directory (or directory tree) against the files and directories listed in the
  180. Benchmark file.  DDIFF compares each file that it finds against the information
  181. included in the Benchmark file, and if anything is different (size, date, time,
  182. or, if /CRC is included, the file's CRC), it reports what has changed by
  183. writing it to a Difference file.
  184.  
  185.  
  186.  
  187. /D-filename
  188.  
  189.      Create a Difference file named 'filename'.  If 'filename' is not speci-
  190. fied, the name DDIFF.DIF is used.  This option is only needed if you wish to
  191. use an alternate Difference file name.
  192.  
  193.      This option is only valid when used with the /C option.
  194.  
  195.  
  196.  
  197. /I-filename
  198.  
  199.      Create an infobase named 'filename' which contains the Differences.  In
  200. order for this option to operate correctly, the program CREATE.EXE (from the
  201. VIEWS package) must be available somewhere in the DOS path.  Using this option
  202. automatically sets the following options:  /C, /U and /O.
  203.  
  204.  
  205.  
  206. /R
  207.  
  208.      No recursive operation.  Use this option to restrict the program to
  209. operation in only one directroy and to ignore all subdirectories.
  210.  
  211.  
  212.  
  213. /CRC
  214.  
  215.      CRC Checking on.  This option will turn on DDIFF's CRC checking feature. 
  216. In order to check the CRC of the files, they need to be read from the disk. 
  217. Since this takes time, using this option makes DDIFF much slower.
  218.  
  219.      Because of the speed limitation, you may want to tell DDIFF to process
  220. only certain files by including a file mask in the path parameter.
  221.  
  222.      For example:
  223.  
  224.      DDIFF /M-EXE.LOG /O /CRC C:\*.EXE
  225.  
  226.      This command would create a Benchmark file named EXE.LOG in the current
  227. directory (/M-EXE.LOG).  If EXE.LOG already existed, it would be overwritten
  228. (/O).  CRC checking will be enabled (/CRC).  All subdirectories would be
  229. processed (no /R).  All .EXE files on logical drive C: would be included in the
  230. Benchmark (C:\*.EXE).
  231.  
  232.      The CRC values given are calculated using an algorithm similar to that
  233. used in various archive programs and file transmission protocols.  The CRC
  234. value is a 16 bit number.  In the .LOG file, the CRC is displayed as four
  235. hexadecimal digits just after the time.
  236.  
  237.      If you see a file that has changed only in its CRC value, watch out, there
  238. may be something funny going on (a virus may be involved).  A file does not
  239. normally change its CRC value without also changing its size, date and/or time. 
  240. If it does, be sure that you understand why (there are instances where this
  241. would not be a problem -- self-modifying programs for example).  If you don't
  242. understand why the CRC value of a file may have changed, I would recommend
  243. finding out why before working with that particular file again.
  244.  
  245.      If a file cannot be opened for reading the CRC (e.g. directories, locked
  246. files, and volume labels), four dashes ('----') will be inserted into the file
  247. instead.
  248.  
  249.      If the /CRC option is not included when checking a Benchmark file that was
  250. created with the /CRC option, CRC checking will not be done and all file CRCs
  251. will be displayed as '----'.
  252.  
  253.      If the /CRC option is included when checking a Benchmark file that was not
  254. created with the /CRC option, CRC checking will not be done and all file CRCs
  255. will be displayed as '----'.
  256.  
  257.  
  258.  
  259. /U
  260.  
  261.      Include unchanged files.  If this option is specified, DDIFF will include
  262. unchanged files in the Difference file (or display).  Normally DDIFF only
  263. reports the files which have changed since the last Benchmark was created. 
  264. This option will allow DDIFF to display ALL files.
  265.  
  266.      When using the /I or /F options, /U is automatically set and cannot be
  267. changed.
  268.  
  269.  
  270.  
  271. /F
  272.  
  273.      This option tells DDIFF to format the Difference file for use with Folio
  274. VIEWS.  A number of markup codes will be inserted into the file which VIEWS
  275. uses to generate a useable infobase.
  276.  
  277.  
  278.  
  279. /O
  280.  
  281.      Overwrite Benchmark file.  If this option is specified, DDIFF will automa-
  282. tically overwrite an existing Benchmark file when creating a new Benchmark.
  283.  
  284.      This option is only valid when used with the /M option.
  285.  
  286.  
  287.  
  288. /A
  289.  
  290.      Append to Benchmark or Difference file.  If this option is specified,
  291. DDIFF will append all information that it produces to an existing Benchmark or
  292. Difference file.  If the file does not exist, it will be created.  For example,
  293. this option could be used when you want your Difference file to be a revision
  294. history of each time that the files have (or have not) changed.
  295.  
  296.  
  297.  
  298. /H
  299.  
  300.      Help.  If this option is specified (anywhere) on the command line, DDIFF
  301. will display its help screen and then exit.
  302.  
  303.  
  304.  
  305. path
  306.  
  307.      The path to begin working on.  If included, the path MUST end with the
  308. backslash character ('\').  If it does not end in a backslash character (e.g.
  309. 'C:\UTIL'), DDIFF will use the intended directory name as a part of the 'file-
  310. spec' parameter (see below).  In the example, instead of using 'C:\UTIL\*.*'
  311. (as intended) DDIFF would use 'C:\UTIL.*' and would only check the files named
  312. 'UTIL.*' in the root directory of drive C:.  
  313.  
  314.  
  315.  
  316. filespec
  317.  
  318.      The filename mask to use when searching for files.  This can include the
  319. wildcard characters '*' and '?.'  If a filename or an extension is not supplied
  320. (e.g. "TEST" or ".DOC" or nothing at all), the wildcard '*' will be supplied
  321. automatically and the examples would become "TEST.*", "*.DOC", and "*.*"
  322. respectively.
  323.  
  324.  
  325.  
  326. Errorlevels returned to DOS
  327.  
  328.      When used with the /C option, DDIFF will return an errorlevel to DOS (for
  329. use in batch files) indicating how many differences it found when comparing
  330. files.  If the number of differences exceeds 200, it will return an errorlevel
  331. of 254.  This was to allow for the following error messages to be reported via
  332. errorlevel.
  333.  
  334.      DDIFF will return the following error codes under the listed
  335. circumstances.
  336.  
  337.    249 ─  Out of Memory.
  338.    250 ─  Couldn't open Header file.  (Only used with the /I option)
  339.   251  ─  Couldn't open Benchmark file.
  340.   252  ─  Couldn't open Difference file.
  341.   253  ─  DDIFF couldn't find anything useful to do.  Most likely, /C or /M was
  342.           not specified.
  343.  
  344.  
  345.      The following segment of text is a batch file that controls what happens
  346. when there are errors or certain numbers of differences.
  347.  
  348.      diff /c /r c:\
  349.      if errorlevel 254 goto lots
  350.      if errorlevel 249 goto error
  351.      if errorlevel 11 goto some
  352.      if errorlevel 1 goto few
  353.      
  354.      :none
  355.      echo There were No Differences.
  356.      goto end
  357.      
  358.      :lots
  359.      echo There were Lots of differences (more than 200).
  360.      goto end
  361.      
  362.      :some
  363.      echo There were Some differences (between 11 and 200).
  364.      goto end
  365.      
  366.      :few
  367.      echo There were a Few differences (between 1 and 10).
  368.      goto end
  369.      
  370.      :error
  371.      echo There was an error running DDIFF (don't know what kind).
  372.      
  373.      :end
  374.      echo Done!
  375.  
  376.      Note the order in which errorlevels are checked.  When DOS sets an error-
  377. level, all lower errorlevels become true.  In other words, if DOS sets the
  378. errorlevel to 100, then 99, 98, and everything down to 0 is set as well.  For
  379. this reason, you must check the highest errorlevels first, and work your way
  380. down to the lower error levels.
  381.  
  382.      When used with the /M option, DDIFF will return the following errorlevels.
  383.  
  384.     0  ─  Successful in creating the Benchmark file.
  385.     1  ─  Terminated because the Benchmark file existed and /O or /A was not
  386.           specified.
  387.    249 ─  Out of memory.
  388.   251  ─  Couldn't open Benchmark file.
  389.   254  ─  DDIFF couldn't find anything useful to do.  Most likely, /C, /M or /I
  390.           was not specified.
  391.  
  392.  
  393.  
  394. A Little Trick
  395.  
  396.      If you use DDIFF to check your entire Hard Drive, you will find that it
  397. will always report that the Benchmark file, and sometimes the Difference file
  398. have been changed since the last run.  In order to get around this, you can
  399. create a hidden directory where DDIFF does not check files for differences.  If
  400. you store your Benchmark and your Difference files in a hidden directory, they
  401. will not be checked for differences when scanning your entire drive.  You will
  402. be able to see if someone has created or deleted a hidden directory, but not if
  403. they have made changes to the files within that directory.
  404.  
  405.      To create a hidden directory requires a specialized utility.  Normal DOS
  406. will not allow you to create a hidden directory.
  407.  
  408.  
  409. Specifications
  410.      DDIFF:
  411.  
  412.     ■     was written, compiled, and linked with Borland C++ 3.0 by Borland.
  413.     ■     has been tested with MS-DOS 3.1, 4.01, and 5.0 and with Digital
  414.                Research's DR DOS 6.0.
  415.     ■     will support up to 2200 files per directory (maximum due to memory
  416.                limitations).
  417.     ■     will support unlimited directories on a single volume (hard disk).
  418.     ■     was designed with command line or batch file operation in mind.
  419.     ■     will be updated if bugs are found or enhancement requests are
  420.                received and implemented.
  421.  
  422.  
  423. Examples
  424.      Here are a few ways that I have found DDIFF can be used.  If you think
  425. your way of using DDIFF could be widely used, let me know so I can document it
  426. here.
  427.  
  428.  
  429.  
  430. Document Management System
  431.  
  432.      This is a very simple use of DDIFF.  It allows many people to make changes
  433. to a group of documents in a given directory and allows you to check the
  434. directory periodically to see if any of the documents have been updated in case
  435. they need to be printed, or otherwise processed.  This was the original reason
  436. DDIFF was written.
  437.  
  438.      To make the Benchmark, type the command:
  439.  
  440.      DDIFF /M-C:\DDIFF.LOG /O C:\DOC\
  441.  
  442.      To check the Benchmark tomorrow (or whenever), type the command:
  443.  
  444.      DDIFF /C-C:\DDIFF.LOG /O C:\DOC\ /D-C:\DDIFF.DIF
  445.  
  446.      The results of these two steps will be a file named DDIFF.DIF in C:\ which
  447. contains a list of file that have changed.
  448.  
  449.  
  450.  
  451. Crude Security System
  452.  
  453.      
  454.      This is one way to make a Benchmark of, and later check, your entire hard
  455. drive.  This is a sort of crude security system that doesn't stop anyone from
  456. making changes to your system, but does tell you what has been changed.
  457.  
  458.      First, to make the Benchmark, you may be logged to any drive or any
  459. directory you choose.  then type the command:
  460.  
  461.      DDIFF /M-C:\C&D.LOG /O /CRC C:\ D:\
  462.  
  463.      DDIFF will create a Benchmark file named C&D.LOG in the root directory of
  464. drive C:.  If a file with that name already existed, DDIFF will overwrite it. 
  465. DDIFF will start in the root directory of drive C: and will process all of the
  466. directories on the entire drive logging all files to C&D.LOG as it goes.  It
  467. will then do the same for drive D:.
  468.  
  469.  
  470.      Then whenever you want to check the entire hard drive against the
  471. Benchmark, type the command:
  472.  
  473.      DDIFF /C-C:\C&D.LOG C:\ D:\ /D-C:\C&D.DIF /CRC
  474.  
  475.      DDIFF will look for an file in the root directory of drive C: named
  476. C&D.LOG.  It will then use this file to compare all directories on drive C:
  477. (starting at the root directory) and log any differences to C&D.DIF in the root
  478. directory of drive C:.  It will do the same for drive D:.  The result will be a
  479. file named C:\C&D.DIF which will contain a list of files that had changed
  480. between the time you made the Benchmark and the time you checked it.
  481.  
  482. Legal stuff
  483.      DDIFF 2.1 is a Freeware product.  It is the property of Doug McKay.  The
  484. program is not sold.  DDIFF 2.1 may be copied freely and distributed by anyone
  485. as long as the original program and documentation files are distributed
  486. together and unchanged.  A reasonable fee may be charged for copying the
  487. program or for a disk with the program on it, but not for the program itself. 
  488. I do not intend to make money from the registrations of DDIFF (hence the
  489. price).
  490.  
  491.      I claim no responsibility for any losses or damages caused by the use or
  492. inability to use this program.  It is distributed without any warranty written
  493. or implied.  I reserve the right to change any terms or options set forth in
  494. this document at any time if I see necessary.
  495.  
  496.      Doug McKay
  497.      549 Kennedy Road
  498.      Windsor, CT  06095-2243
  499.      (203) 298-9278  (voice)
  500.      (801) 375-9907  (BBS)
  501.      CIS: 72010,520
  502.